package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.TMonthProfitBillInfo;
import com.ruoyi.statistic.service.ITMonthProfitBillInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月利润表Controller
 * 
 * @author wzy
 * @date 2024-12-01 10:06:39
 */
@RestController
@RequestMapping("/statistic/monthprofit")
public class TMonthProfitBillInfoController extends BaseController
{
    @Autowired
    private ITMonthProfitBillInfoService tMonthProfitBillInfoService;

    /**
     * 查询月利润表列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthprofit:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMonthProfitBillInfo tMonthProfitBillInfo)
    {
        startPage();
        List<TMonthProfitBillInfo> list = tMonthProfitBillInfoService.selectTMonthProfitBillInfoList(tMonthProfitBillInfo);
        return getDataTable(list);
    }

    /**
     * 导出月利润表列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthprofit:export')")
    @Log(title = "月利润表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMonthProfitBillInfo tMonthProfitBillInfo)
    {
        List<TMonthProfitBillInfo> list = tMonthProfitBillInfoService.selectTMonthProfitBillInfoList(tMonthProfitBillInfo);
        ExcelUtil<TMonthProfitBillInfo> util = new ExcelUtil<TMonthProfitBillInfo>(TMonthProfitBillInfo.class);
        util.exportExcel(response, list, "月利润表数据");
    }

    /**
     * 获取月利润表详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthprofit:query')")
    @GetMapping(value = "/{profitBillId}")
    public AjaxResult getInfo(@PathVariable("profitBillId") Long profitBillId)
    {
        return success(tMonthProfitBillInfoService.selectTMonthProfitBillInfoByProfitBillId(profitBillId));
    }

    /**
     * 新增月利润表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthprofit:add')")
    @Log(title = "月利润表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMonthProfitBillInfo tMonthProfitBillInfo)
    {
        tMonthProfitBillInfo.setCreateBy(getNickName());
        return toAjax(tMonthProfitBillInfoService.insertTMonthProfitBillInfo(tMonthProfitBillInfo));
    }

    /**
     * 修改月利润表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthprofit:edit')")
    @Log(title = "月利润表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMonthProfitBillInfo tMonthProfitBillInfo)
    {
        tMonthProfitBillInfo.setUpdateBy(getNickName());
        return toAjax(tMonthProfitBillInfoService.updateTMonthProfitBillInfo(tMonthProfitBillInfo));
    }

    /**
     * 删除月利润表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthprofit:remove')")
    @Log(title = "月利润表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{profitBillIds}")
    public AjaxResult remove(@PathVariable Long[] profitBillIds)
    {
        return toAjax(tMonthProfitBillInfoService.deleteTMonthProfitBillInfoByProfitBillIds(profitBillIds));
    }
}
